﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl

Public Class mediaplayer
    Inherits div

    Public Class datasource
        Public link As String = Nothing
        Public isIEUserAgent As Boolean = True
        Public type As String = Nothing
    End Class

    Public Sub setData(ByVal ds As datasource)
        assert(Not ds Is Nothing, "ds is nothing.")
        assert(Not isemptystring(ds.link), "ds.link is empty string.")

        If ds.isIEUserAgent Then
            Dim wmp As wmp = Nothing
            wmp = New wmp()
            addchild(wmp)

            wmp.addurl(ds.link)
            wmp.addAutoStart("-1")
            wmp.addplaycount(maxInt32)
            wmp.addvolume("100")
        Else
            Dim obj As [object] = Nothing
            obj = New [object]()
            obj.data = ds.link
            obj.type = ifoper(isemptystring(ds.type), contentTypes.getdefaultContentType(ds.link), ds.type)
            addchild(obj)

            Dim param As param = Nothing
            param = New param()
            param.name = "src"
            param.value = ds.link
            obj.addchild(param)
        End If
    End Sub

    Public Sub New(ByVal ds As datasource, Optional ByVal buff As Stream = Nothing)
        Me.New(buff)
        setData(ds)
    End Sub

    Public Sub New(Optional ByVal buff As Stream = Nothing)
        MyBase.New(buff)
    End Sub
End Class
